import { defineStore } from 'pinia'

export const useMyStore = defineStore('myStore', {
  state:()=>{
    return {
      router:'',
      params:{}, // 请求参数
      user:{}
    }
  },
  actions:{
    login(user) {
      this.$patch({
        user:user
      });
      localStorage.setItem('vuser', JSON.stringify(user)); 
      document.cookie = "username=xuezhr"
    },
    logout(){
      this.$patch({
        user:{}
      })
      localStorage.removeItem('vuser');
      document.cookie = "username='"
    }
  },
  persist:true
})